<?php
use Base\AdminController;
use JetBrains\PhpStorm\NoReturn;

class ExamsubjectController extends AdminController
{
    protected string $table = 'exam_subjects';

    protected string $model = "examSubject";

    /**
     * 初始化
     */
    #[NoReturn] public function init(): void
    {
        if (Request::input("title")) {
            $this->where[] = ['title','like', '%'.Request::input("title").'%'];
        }
        $this->routeWhiteLst = ['examsubject@getoptions','examsubject@getlist'];
        parent::init();

    }

    #[NoReturn] public function getOptionsAction(): void
    {
        $data = dict('exam_grade');
        $result = [];
        foreach ($data as $key=>$vo) {
            $result[] = [
                'value'=>(int)$vo,
                'label'=>$key
            ];
        }
        $this->apiSuccess($result,"获取成功",20000);
    }

    #[NoReturn] public function getListAction(): void
    {
        $data = ExamSubjectModel::query()->get()->toArray();
        $this->apiSuccess($data,"获取成功",20000);
    }
}
